import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';

import { DictEnum } from '@vben/constants';

import { renderDict } from '#/utils/render';

export const querySchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    fieldName: 'taskName',
    label: '任务名称',
  },
  {
    component: 'Input',
    fieldName: 'keyWord',
    label: '关键字',
  },
  {
    component: 'Input',
    fieldName: 'eventName',
    label: '事件名称',
  },
];

export const columns: VxeGridProps['columns'] = [
  {
    title: '任务名称',
    field: 'taskName',
  },
  {
    title: '关键字',
    field: 'keyWord',
  },
  {
    title: '开始时间',
    field: 'startTime',
  },
  {
    title: '结束时间',
    field: 'endTime',
  },
  {
    title: '状态',
    field: 'status',
    slots: {
      default: ({ row }) => {
        return renderDict(row.status, DictEnum.DATA_COLLECT_STATUS);
      },
    },
  },
  {
    title: '事件名称',
    field: 'eventName',
  },
  {
    title: '创建者',
    field: 'createBy',
  },
  {
    title: '修改者',
    field: 'updateBy',
  },
  {
    title: '创建时间',
    field: 'createTime',
  },
  {
    field: 'action',
    fixed: 'right',
    slots: { default: 'action' },
    title: '操作',
    resizable: false,
    width: 'auto',
  },
];

export const modalSchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    fieldName: 'taskName',
    label: '任务名称',
    rules: 'required',
  },
  {
    component: 'Input',
    fieldName: 'keyWord',
    label: '关键字',
    rules: 'required',
  },
  {
    component: 'Input',
    fieldName: 'eventName',
    label: '事件名称',
    rules: 'required',
  },
  {
    fieldName: 'startTime',
    component: 'DatePicker',
    label: '开始时间',
    componentProps: {
      showTime: true, // 启用时间选择
      valueFormat: 'YYYY-MM-DD HH:mm:ss', // 包含秒
      format: 'YYYY-MM-DD HH:mm:ss',
    },
  },
  {
    fieldName: 'endTime',
    component: 'DatePicker',
    label: '结束时间',
    componentProps: {
      showTime: true, // 启用时间选择
      valueFormat: 'YYYY-MM-DD HH:mm:ss', // 包含秒
      format: 'YYYY-MM-DD HH:mm:ss',
    },
  },
];
